﻿
    using Maticsoft.BLL;
    using Maticsoft.Model;
    using System;
    using System.Text;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public partial class WebPage_DiaoCha_Wenti_Bianji : SystemBBasePage
    {
     

        private void getValue(int id)
        {
            Maticsoft.Model.vote_question _question = new Maticsoft.Model.vote_question();
            Maticsoft.BLL.vote_question _question2 = new Maticsoft.BLL.vote_question();
            StringBuilder builder = new StringBuilder();
            StringBuilder builder2 = new StringBuilder();
            foreach (Maticsoft.Model.vote_question _question3 in _question2.GetModelList("id=" + id.ToString()))
            {
                this.title1.Value = _question3.Title;
                if (_question3.Type == "radio")
                {
                    builder.Append("  <input type='radio' name='type' value='radio' checked/>单选");
                    builder.Append(" <input type='radio' name='type' value='checkbox' />多选");
                }
                else if (_question3.Type == "checkbox")
                {
                    builder.Append("  <input type='radio' name='type' value='radio' />单选");
                    builder.Append(" <input type='radio' name='type' value='checkbox' checked />多选");
                }
                if (_question3.is_show == 1)
                {
                    builder2.Append("<input type='radio' name='is_show' value='1' checked/>显示 ");
                    builder2.Append("<input type='radio' name='is_show' value='0' />隐藏");
                }
                else if (_question3.is_show == 0)
                {
                    builder2.Append("<input type='radio' name='is_show' value='1' />显示 ");
                    builder2.Append("<input type='radio' name='is_show' value='0' checked/>隐藏");
                }
                this.order_name.Value = _question3.order.ToString();
                this.update.Value = _question3.id.ToString();
            }
            this.Literal1.Text = builder.ToString();
            this.Literal2.Text = builder2.ToString();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.HeaderControl1.Select = "diaocha";
            this.DiaoCha1.Select = "Wenti";
            if (base.Request.HttpMethod == "POST")
            {
                this.setValue();
            }
            if (!base.IsPostBack && (base.Request.QueryString["edit"] != null))
            {
                this.getValue(int.Parse(base.Request.QueryString["edit"].ToString()));
            }
        }

        private void setValue()
        {
            Maticsoft.Model.vote_question model = new Maticsoft.Model.vote_question();
            Maticsoft.BLL.vote_question _question2 = new Maticsoft.BLL.vote_question();
            model.id = int.Parse(this.update.Value);
            model.is_show = int.Parse(base.Request.Form["is_show"].ToString());
            try
            {
                model.order = int.Parse(this.order_name.Value);
            }
            catch (Exception)
            {
            }
            model.Title = this.title1.Value;
            model.Type = base.Request.Form["type"].ToString();
            _question2.Update(model);
            base.Response.Redirect("DiaoCha_Wenti.aspx");
        }
    }


